package com.ks.core.config;

import com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan("com.kd.*.dao.*")
public class MybatisPlusConfig {

    /**
     * mybatis-plus性能分析插件
     *
     * @return
     */
//    @Bean
//    public PerformanceInterceptor performanceInterceptor() {
//        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
//        //SQL执行性能分析,开发环境使用,线上不推荐 maxTime指的是sql最大执行时长
//        performanceInterceptor.setMaxTime(1000);
//        //SQL是否格式化 默认false
//        performanceInterceptor.setFormat(true);
//        return performanceInterceptor;
//    }

    /**
     * mybatis-plus分页插件
     *
     * @return
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    /**
     * mybatis-plus乐观锁插件
     *
     * @return
     */
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
        return new OptimisticLockerInterceptor();
    }

}
